package com.easy.work.function.me;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.base.syslib.util.MessageTools;
import com.base.syslib.util.TextUtil;
import com.easy.work.R;
import com.easy.work.app.AppSession;
import com.easy.work.app.BaseActivity;
import com.easy.work.http.BaseResponse;
import com.easy.work.http.HttpClient;
import com.easy.work.http.request.GetResumeInfoRequest;
import com.easy.work.http.response.ResumeInfoResponse;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by admin on 2017/12/28.
 * 我的邀请码
 */
public class InvitationCodeAct extends BaseActivity {
    @BindView(R.id.title_left_back)
    RelativeLayout titleLeftBack;
    @BindView(R.id.tv_invitation_code)
    TextView tvInvitationCode;
    private String inviteCode;

    public static void startActivity(Context context, String inviteCode) {
        Intent intent = new Intent(context, InvitationCodeAct.class);
        if (TextUtil.isNotNull(inviteCode))
            intent.putExtra("inviteCode", inviteCode);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act__invitation_code);
        ButterKnife.bind(this);
        if (getIntent() != null && getIntent().hasExtra("inviteCode")) {
            inviteCode = getIntent().getStringExtra("inviteCode");
            tvInvitationCode.setText(inviteCode);
        } else {
            getResumeInfo();
        }
    }

    @OnClick(R.id.title_left_back)
    public void onViewClicked() {
        finish();
    }

    /**
     * 获取简历信息
     */
    private void getResumeInfo() {
        GetResumeInfoRequest request = new GetResumeInfoRequest();
        request.userId = AppSession.getInstance().getUserId();
        HttpClient.post(request, new HttpClient.onSuccessListener() {
            @Override
            public void onSuccess(BaseResponse response) {
                ResumeInfoResponse resumeInfoResponse = (ResumeInfoResponse) response;


            }
        }, new HttpClient.onFailListener() {
            @Override
            public void onFail(int code, String msg) {
                MessageTools.showToast(oThis, msg);
            }
        });
    }
}
